<!DOCTYPE html>
<html lang="ch-cn" xmlns:th="http://www.thymeleaf.org">
<head th:replace="layouts::header"></head>
<body>
    <nav th:replace="layouts::navbar"></nav>
    <div class="container">
        <h3>学生</h3>
        <hr>
        <a th:href="@{/students/new}" class="btn btn-primary btn sm mb-3">新增学生</a>
        <br>
        <!--    在thymeleaf模板引擎中，th:each属性表示遍历，th:text表示将元素内容替换成传入的文本。-->
        <table class="table table-bordered table-striped">
            <thead class="thead-dark">
            <tr>
                <th>学生名字</th>
                <th>学生微信</th>
                <th>email</th>
                <th>动作</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="aStudent : ${students}">
                <td th:text="${aStudent.name}"></td>
                <td th:text="${aStudent.wechatId}"></td>
                <td th:text="${aStudent.email}"></td>
                <td><a th:href="@{/students/updata(id=${aStudent.studentId})}"
                    class="btn btn-info btn-sm"
                    >更新</a>
                    <a th:href="@{/students/delete(id=${aStudent.studentId})}"
                       class="btn btn-danger btn-sm"
                       onclick="if (!(confirm('确定?')))return false"
                    >删除</a>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</body>
</html>